knitr::opts_chunk$set(echo = TRUE)

library(tibble)
library(dplyr)

#Literacy rate Y is predicted by number of X- newspapers bought per week, and T- televisions per family, per 1000 people in each country- Poland, Italy, Scotland , Sweden.

country <- c("Poland", "Italy", "Scotland", "Sweden")
Newspapers <- c(280,100,14,130)
Television <- c(440,22,180,147)
Literacy <- c(.15,.98,.49,.29)

data <- tibble(X = c(280,100,14,130),
               T = c(440,22,180,147),
               Y = c(.15,.98,.49,.29))



(overall_model <- summary(lm(Literacy~Television+Newspapers, data=data)))


cor(data)
lm.x <- lm(Literacy~Newspapers, data=data)
#correlation between both independent variables(newspaper and tv's)
lm.newspaper_tv <- lm(X~T, data=data)
#part of newspapers that is not correlated with TV's....
residuals(lm.newspaper_tv)

The newspaper variable and solely its association rate with Literacy Rates for each country.

cor(residuals(lm.newspaper_tv),data$Y)^2 


AmandaPMurphy/SemesterProjectLabII documentation built on May 23, 2022, 3:16 p.m.